<?php
	function displayPage()
	{
		$verify = get('tick');
		if(get('tick') != 'null')
		{
			if(isset($verify[5]) && $verify[11])
			{
				if($verify[5] == '0' && $verify[11] == '1')
				{
					if(post('tick') != 'null')
					{
						$tick = post('tick');
						if($tick[5] == '6' && $tick[11] == '3' && post('pass') != '' && post('pass') == post('cpass'))
						{
							$tables = array();
							$tables[0] = 'ex_shoppers';
							
							$fields = array();
							$fields[0] = 'memberID';
							
							$whereClause = 'email="'.post('email').'"';
							
							$data = SQLRecover($tables, $fields, $whereClause);
							
							if($data['queryStatus'] == 'DB Query success!')
							{
								$s = array(' ', '.', '\'', '"', '%', '^', '&', '<', '>', '!', '?', '$');
								$r = array('_spc_', '_dt_', '_sq_', '_dq_', '_pc_', '_pwr_', '_amp_', '_lt_', '_gt_', '_ex_', '_qm_', '_dr_');
								$filtPass = str_ireplace($s, $r, post('pass'));
								$view = sendThisEmail('Your new password is: <b>'.$filtPass.'</b><br /><br />Please go to the link below to make your change effective:<br />'.INDEX.'fp'.EXT.'tick='.rand(10000,99999).'5'.rand(10000,99999).'2'.rand(10000,99999).'&email='.post('email').'&newpass='.$filtPass, 'Your Password Changes', '', '', post('email'), 'site@soleservice.com.ph', verifyEmail(post('email')));
								$output = '
								<div class="container_12">
									<div class="grid_12">
										<p>
											<h2>Forgot your Password?</h2>
										</p>
										Your new change password request link has been sent to your email address. Please click the link we just sent to your email address for your change to be effective.
									</div>
								</div>
								';
							}
							else
							{
								$output = '
								<div class="container_12">
									<div class="grid_12">
										<p>
											<h2>Forgot your Password?</h2>
										</p>
										<form method="POST" action="'.INDEX.'fp'.EXT.'tick='.rand(10000,99999).'0'.rand(10000,99999).'1'.rand(10000,99999).'">
										<input type="hidden" value="'.rand(10000,99999).'6'.rand(10000,99999).'3'.rand(10000,99999).'" name="tick" />
										<table>
											<tr>
												<td colspan="2" class="tHeader">
													Your email address does not seem to be registered. Click <a href="'.INDEX.'cart'.EXT.'sign=up"><u>here</u></a> to create a new account. If you wish to try again, re-enter your email address below and your new password. A confirmation link regarding your change of password will appear in your email account. Only by clicking this link will your password change effective.
												</td>
											</tr>
											<tr>
												<td class="tdL">
													Email:
												</td>
												<td class="tdR">
													<input type="text" name="email"/>
												</td>
											</tr>
											<tr>
												<td class="tdL">
													Password:
												</td>
												<td class="tdR">
													<input type="password" name="pass"/>
												</td>
											</tr>
											<tr>
												<td class="tdL">
													Confirm Password:
												</td>
												<td class="tdR">
													<input type="password" name="cpass"/>
												</td>
											</tr>
											<tr>
												<td colspan="2" class="tdB">
													<input type="submit" value="Confirm Password Change" />
												</td>
											</tr>
										</table>
										</form>
									</div>
								</div>
								';

							}
						}
					}
					else
					{
						$output = '
						<div class="container_12">
							<div class="grid_12">
								<p>
									<h2>Forgot your Password?</h2>
								</p>
								<form method="POST" action="'.INDEX.'fp'.EXT.'tick='.rand(10000,99999).'0'.rand(10000,99999).'1'.rand(10000,99999).'">
								<input type="hidden" value="'.rand(10000,99999).'6'.rand(10000,99999).'3'.rand(10000,99999).'" name="tick" />
								<table>
									<tr>
										<td colspan="2" class="tHeader">
											If you do not have a password, click <a href="'.INDEX.'cart'.EXT.'sign=up"><u>here</u></a> to create a new account. Enter your email address below and your new password. A confirmation link regarding your change of password will appear in your email account. Only by clicking this link will your password change effective.
										</td>
									</tr>
									<tr>
										<td class="tdL">
											Email:
										</td>
										<td class="tdR">
											<input type="text" name="email"/>
										</td>
									</tr>
									<tr>
										<td class="tdL">
											Password:
										</td>
										<td class="tdR">
											<input type="password" name="pass"/>
										</td>
									</tr>
									<tr>
										<td class="tdL">
											Confirm Password:
										</td>
										<td class="tdR">
											<input type="password" name="cpass"/>
										</td>
									</tr>
									<tr>
										<td colspan="2" class="tdB">
											<input type="submit" value="Confirm Password Change" />
										</td>
									</tr>
								</table>
								</form>
							</div>
						</div>
						';
					}
					
				}
				else if($verify[5] == '5' && $verify[11] == '2')
				{
					//update change here
					$email = get('email');
					$pass = get('newpass');
					if($email == 'null' || $pass == 'null')
					{
						$output = redirectSiteNow(INDEX.'404').'Please re-enable Java Script. Thanks.';
					}
					else
					{
						$tableName = 'ex_shoppers';
						
						$fields = array();
						$fields[0] = 'passphrase';
						
						$values = array();
						$values[0] = crypt(strip_tags($pass), 'ssmain0505032');
						
						$whereClause = 'email="'.$email.'"';
						
						$data = SQLUpdate($tableName, $whereClause, $fields, $values);
						$output = redirectSiteNow(INDEX.'cart?renew=yes').'Please re-enable Java Script. Thanks.';
					}
				}
				else
				{
					$output = redirectSiteNow(INDEX.'404').'Please re-enable Java Script. Thanks.';
				}
			}
		}
		else
		{
			$output = redirectSiteNow(INDEX.'404').'Please re-enable Java Script. Thanks.';
		}
		
		return $output;
	}
?>